﻿using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using MediaPortal.Configuration;
using MPMovieCatalog.Service;
using log4net;

namespace MPMovieCatalog
{
    public class MPMovieCatalogServer
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(MPMovieCatalogServer));

        public static void Start(int port)
        {
            log.Info("Starting MPMovieCatalog server...");

            ChannelServices.RegisterChannel(new HttpServerChannel("mpmcHttp", port), false);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(MovieService)
                    , "MovieService", WellKnownObjectMode.Singleton);

            log.Info(string.Format("MPMovieCatalog server started on port {0:d}", port));
        }

    }
}
